            .model small
            .stack
            .data
            mess1  db  13,10, "Nhap vao 1 chuoi nhi phan: $"
            mess2  db  13,10, "So thap phan: $"
            messkt  db  13,10, "Nhan 1 phim de ket thuc...!$"            
            .code                                          
            
            mov dx,seg mess1
            mov ds,dx                                      
            
            ;thong bao nhap
            N1:
            mov ah,9
            lea dx,mess1
            int 21h            
            
            mov bx,0    ;xoa bit
            mov cx,0    ;xoa bit
            
            Nhap:
            mov ah,1            
            int 21h            
            cmp al,13  ;kiem tra al=13
            je  kt          
            cmp al,30h
            jb  N1
            cmp al,31h
            ja  N1                
            sub al,30h 
            mov bl,al                      
            push bx  
            inc cx
            jmp Nhap
            
            kt:      
            ;thong bao xuat
            mov ah,9
            lea dx,mess2
            int 21h                                                        
            
            ;Doi tu he 2 sang he 10  
            mov bx,0
            mov si,0
            Doi:
            pop dx
            cmp dx,0
            je  tiep    ;neu dx=0 thi khong cong them  
            call laymu  ;goi ham lay mu            
            add bx,ax 
            tiep:
            inc si
            loop Doi              
            
            mov ax,bx
            call xuatax ;goi ham xuatax
            
            ;thong bao ket thuc
            mov ah,9
            lea dx,messkt
            int 21h
            
            mov ah,1
            int 21h
            
            mov ah,4ch
            int 21h
            xuatax proc
                pop si
                mov bx,10
                mov cx,0 
                
                chia:
                mov dx,0
                div bx      ;chia ax cho bx <=>ax=ax/bx, so du dat o dx
                push dx 
                inc cx                
                cmp ax,0    ;kiem ax>0 thi tiep tuc chia
                ja  chia
                
                mov ah,2
                xuatkqax:
                pop dx
                add dl,30h
                int 21h                
                loop xuatkqax
                
                push si
                ret
            endp xuatax
            
            laymu proc  
                mov ax,1    
                cmp si,0    ;kiem tra si=0 <=> tinh mu~=0 => tra ve ax=1
                je  s                  
                mov ax,2    ;kiem tra si=1 <=> tinh mu~=1 => tra ve ax=2
                cmp si,1
                je  s                      
                push cx    ;gan cx=dia chi lenh ke tiep 
                mov cx,si  
                dec cx
                  
                nhanmu:    ;vong lap tinh so mu~
                mov dx,2
                mul dx 
                loop nhanmu
                pop cx      ;dua dia chi lenh ke tiep vao stack
                s:
                ret
            laymu endp
            
            end

